package com.nmsl.nurse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.nurse.domain.MDischargeRecord;
import com.nmsl.nurse.service.MIDischargeRecordService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 出院记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/nurse/chuyuan")
public class MDischargeRecordController extends BaseController
{
    @Autowired
    private MIDischargeRecordService dischargeRecordService;

    /**
     * 查询出院记录列表
     */
//    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:list')")
    @GetMapping("/list")
    public TableDataInfo list(MDischargeRecord MDischargeRecord)
    {
        startPage();
        List<MDischargeRecord> list = dischargeRecordService.selectDischargeRecordList(MDischargeRecord);
        return getDataTable(list);
    }

    /**
     * 导出出院记录列表
     */
    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:export')")
    @Log(title = "出院记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MDischargeRecord MDischargeRecord)
    {
        List<MDischargeRecord> list = dischargeRecordService.selectDischargeRecordList(MDischargeRecord);
        ExcelUtil<MDischargeRecord> util = new ExcelUtil<MDischargeRecord>(MDischargeRecord.class);
        util.exportExcel(response, list, "出院记录数据");
    }

    /**
     * 获取出院记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:query')")
    @GetMapping(value = "/{dischargeRecordId}")
    public AjaxResult getInfo(@PathVariable("dischargeRecordId") Long dischargeRecordId)
    {
        return success(dischargeRecordService.selectDischargeRecordByDischargeRecordId(dischargeRecordId));
    }

    /**
     * 新增出院记录
     */
    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:add')")
    @Log(title = "出院记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MDischargeRecord MDischargeRecord)
    {
        return toAjax(dischargeRecordService.insertDischargeRecord(MDischargeRecord));
    }

    /**
     * 修改出院记录
     */
    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:edit')")
    @Log(title = "出院记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MDischargeRecord MDischargeRecord)
    {
        return toAjax(dischargeRecordService.updateDischargeRecord(MDischargeRecord));
    }

    /**
     * 删除出院记录
     */
    @PreAuthorize("@ss.hasPermi('nurse:chuyuan:remove')")
    @Log(title = "出院记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dischargeRecordIds}")
    public AjaxResult remove(@PathVariable Long[] dischargeRecordIds)
    {
        return toAjax(dischargeRecordService.deleteDischargeRecordByDischargeRecordIds(dischargeRecordIds));
    }
}
